//#ifndef CODER_H
//#define CODER_H

#include "pgm_io.h"
#include "macro_defs.h"

void dec_to_bin_print(int n , int digits, FILE * dest);

/** 
 * 
 * 
 * @param matrix: 2D matrix built from8bpp pgm P5 image.
 * @param i: Row index.
 * @param j: Column index.
 * @param context_abcd: Context will be returned here.
 * 
 */
void context(PGMData * image, int i, int j, int * context_abcd);

/**
 * 
 * 
 * @param context_abcd: Context to use for prediction.
 * 
 * @return: predicted pixel value.
 */
int predictor(int * context_abcd);

/** 
 * 
 * 
 * @param image : data read from PGM image.
 * @param i : current row.
 * @param j : current column.
 * @param prediction : predicted pixel for [i][j]
 * 
 * @return : error (predicted-real) calculated for [i][j] (0<=error,512)
 */
int pred_error(PGMData * image, int i, int j, int prediction);

/** 
 * 
 * 
 * @param image: Data read from image to encode.
 * @param N: Encoder parameter.
 * @param filename: Compressed data will be written to filename.
 * 
 * @return: Number of bits written to  compressed file.
 */
int encode(PGMData * image, int N, char * filename);

/** 
 * 
 * 
 * @param image: Data read from decoded image.
 * @param N: Encoder parameter.
 * @param filename: Decompressed data will be written to filename.
 * 
 */
void decode(PGMData * image, char * filename);

void read_bit(int * var, FILE * file);

//#endif
